---
category: Array
contributors:
    - vreymond
created: '2020-05-09'
title: Remove falsy values from array
updated: '2021-10-22'
---

**JavaScript version**

```js removeFalsy.js
const removeFalsy = (arr) => arr.filter(Boolean);
```

**TypeScript version**

```ts removeFalsy.ts
const removeFalsy = <T,_>(arr: T[]): T[] => arr.filter(Boolean);
```

**Example**

```js example.js
removeFalsy([0, 'a string', '', NaN, true, 5, undefined, 'another string', false]);
// ['a string', true, 5, 'another string']
```
